<template>
  <div class="mine">
    <!-- 头部 -->
    <div class="profile">
      <van-image round fit="cover" :src="userInfo.photo" />
      <div class="info">
        <h4>{{ userInfo.name }}</h4>
        <span>{{ userInfo.birthday }}</span>
      </div>
    </div>
    <!-- 中部 -->
    <van-row>
      <van-col span="8">
        <van-icon color="#94afff" name="newspaper-o" />
        <span>我的作品</span>
      </van-col>
      <van-col span="8">
        <van-icon color="#f00" name="star-o" />
        <span>我的收藏</span>
      </van-col>
      <van-col color="#ffaf6b" span="8">
        <van-icon name="tosend" />
        <span>阅读历史</span>
      </van-col>
    </van-row>
    <!-- 尾部 -->
    <van-cell-group>
      <van-cell to="/mine/edit" icon="edit" title="编辑资料" is-link />
      <van-cell to="/mine/chat" icon="chat-o" title="小智同学" is-link />
      <van-cell icon="setting-o" title="系统设置" is-link />
      <van-cell @click="logout" icon="info-o" title="退出登录" is-link />
    </van-cell-group>
  </div>
</template>

<script>
export default {
  data() {
    return {};
  },

  created() {
    this.$store.dispatch("getUserInfo");
  },

  methods: {
    logout() {
      this.$store.commit("logout");
      this.$toast.success("退出成功");
      this.$router.push("/login");
    },
  },

  computed: {
    userInfo() {
      return this.$store.state.userInfo;
    },
  },
};
</script>

<style lang="less" scoped>
.mine {
  @bgColor: #3296fa;

  .profile {
    height: 160px;
    background-color: @bgColor;
    display: flex;
    align-items: center;

    .van-image {
      width: 100px;
      height: 100px;
      margin-left: 20px;
      margin-right: 20px;
    }

    .info {
      h4 {
        color: #fff;
        font-size: 16px;
        margin-bottom: 15px;
      }

      span {
        background-color: #fff;
        padding: 5px;
        font-weight: 700;
        color: @bgColor;
      }
    }
  }

  .van-row {
    .van-col {
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      height: 80px;

      .van-icon {
        font-size: 30px;
        margin-bottom: 5px;
      }
    }
  }
}
</style>
